package com.ruoyi.web.controller.datastatistics;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.datastatistics.domain.DeviceInstall;
import com.ruoyi.datastatistics.service.IDeviceInstallService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 安装数据上传Controller
 * 
 * @author ruoyi
 * @date 2023-10-20
 */
@RestController
@RequestMapping("/datastatistics/deviceinstall")
public class DeviceInstallController extends BaseController
{
    @Autowired
    private IDeviceInstallService deviceInstallService;

    /**
     * 查询安装数据上传列表
     */
    @PreAuthorize("@ss.hasPermi('datastatistics:deviceinstall:list')")
    @GetMapping("/list")
    public TableDataInfo list(DeviceInstall deviceInstall)
    {
        startPage();
        List<DeviceInstall> list = deviceInstallService.selectDeviceInstallList(deviceInstall);
        return getDataTable(list);
    }

    /**
     * 导出安装数据上传列表
     */
    @PreAuthorize("@ss.hasPermi('datastatistics:deviceinstall:export')")
    @Log(title = "安装数据上传", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DeviceInstall deviceInstall)
    {
        List<DeviceInstall> list = deviceInstallService.selectDeviceInstallList(deviceInstall);
        ExcelUtil<DeviceInstall> util = new ExcelUtil<DeviceInstall>(DeviceInstall.class);
        util.exportExcel(response, list, "安装数据上传数据");
    }

    /**
     * 获取安装数据上传详细信息
     */
    @PreAuthorize("@ss.hasPermi('datastatistics:deviceinstall:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(deviceInstallService.selectDeviceInstallById(id));
    }

    /**
     * 新增安装数据上传
     */
    @PreAuthorize("@ss.hasPermi('datastatistics:deviceinstall:add')")
    @Log(title = "安装数据上传", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DeviceInstall deviceInstall)
    {
        return toAjax(deviceInstallService.insertDeviceInstall(deviceInstall));
    }

    /**
     * 修改安装数据上传
     */
    @PreAuthorize("@ss.hasPermi('datastatistics:deviceinstall:edit')")
    @Log(title = "安装数据上传", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DeviceInstall deviceInstall)
    {
        return toAjax(deviceInstallService.updateDeviceInstall(deviceInstall));
    }

    /**
     * 删除安装数据上传
     */
    @PreAuthorize("@ss.hasPermi('datastatistics:deviceinstall:remove')")
    @Log(title = "安装数据上传", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(deviceInstallService.deleteDeviceInstallByIds(ids));
    }
}
